<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>JSON</title>
</head>
<body>

</body>
<script>
    let weather={
        city:{province:"xx",cityName:""},//json对象
        date:"2088-08-08",//string
        wendu:[{time:"shangwu",dushu:10},{time:"xiawu",dushu:20}],//json数组
        shidu:"22%",//string
        wind:true,//boolean
        windGrade:5,//number
        xxx:null
    }
    //1.将天气对象转换成JSON格式的字符串
    let str = JSON.stringify(weather);
    document.write(str+"<br>");
    //2.将JSON格式字符串解析成JS对象
    let weather2=JSON.parse(str);
    document.write("城市:"+weather2.city.cityName+"<br>");
    document.write("日期:"+weather2.date+"<br>");
    document.write("温度:"+weather2.wendu[0].time+weather2.wendu[0].dushu+"<br>");
    document.write("湿度:"+weather2.shidu+"<br>");
</script>
</html>